package com.example.mymusicplayer;

import static com.example.mymusicplayer.MainActivity.Album;
import static com.example.mymusicplayer.MainActivity.musicFiles;

import android.os.Bundle;

import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


public class AlbumFragment extends Fragment {
    RecyclerView recyclerView;
    AlbumAdapter albumAdapter;



    public AlbumFragment() {
        // Required empty public constructor
    }



    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_album, container, false);
        recyclerView=view.findViewById(R.id.RecycleViewForAlbum);
        DividerItemDecoration dI = new DividerItemDecoration(view.getContext(), DividerItemDecoration.HORIZONTAL);
        recyclerView.addItemDecoration(dI);
        recyclerView.setHasFixedSize(true);

        if(!(Album.size()<1)){
            Log.e("The Adapter is Trigger","ok!");
            System.out.println(musicFiles);
           albumAdapter =new AlbumAdapter(getContext(),Album);
            recyclerView.setAdapter(albumAdapter);
            recyclerView.setLayoutManager(new GridLayoutManager(getContext(), 2));
        }
        else
            Log.e("The Adapter is Trigger","null");
        return view;
    }
}